﻿using System.Web.Http;
using Eagles.Interface.Core;
using Eagles.Application.Host.Common;
using Eagles.Application.Model.Chart.Request;
using Eagles.Application.Model.Chart.Response;

namespace Eagles.Application.Host.Controllers
{
    /// <summary>
    /// 
    /// </summary>
    public class ChartController : ApiController
    {
        private readonly IChartHandler _chartHandler;

        public ChartController(IChartHandler chartHandler)
        {
            this._chartHandler = chartHandler;
        }

        /// <summary>
        /// 饼图
        /// </summary>
        /// <param name="requset"></param>
        /// <returns></returns>
        [HttpPost]
        public ResponseFormat<PieChartResponse> GetPieChart(PieChartRequest requset)
        {
            return ApiActuator.Runing(requset, (requset1) => _chartHandler.GetPieChart(requset));
        }

        /// <summary>
        /// 柱状图
        /// </summary>
        /// <param name="requset"></param>
        /// <returns></returns>
        [HttpPost]
        public ResponseFormat<HistogramResponse> GetHistogram(HistogramRequest requset)
        {
            return ApiActuator.Runing(requset, (requset1) => _chartHandler.GetHistogram(requset));
        }

        /// <summary>
        /// 线图
        /// </summary>
        /// <param name="requset"></param>
        /// <returns></returns>
        [HttpPost]
        public ResponseFormat<LineChartResponse> GetLineChart(LineChartRequest requset)
        {
            return ApiActuator.Runing(requset, (requset1) => _chartHandler.GetLineChart(requset));
        }
        
        /// <summary>
        /// 任务活动饼图
        /// </summary>
        /// <param name="requset"></param>
        /// <returns></returns>
        [HttpPost]
        public ResponseFormat<TaskActivityPieResponse> GetTaskActivityPie(TaskActivityPieRequest requset)
        {
            return ApiActuator.Runing(requset, (requset1) => _chartHandler.GetTaskActivityPie(requset));
        }
    }
}